package com.huike.web.controller.report;


import com.huike.business.mapper.TbBusinessMapper;
import com.huike.clues.mapper.SysDeptMapper;
import com.huike.clues.mapper.SysUserMapper;
import com.huike.clues.mapper.TbClueMapper;
import com.huike.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    TbClueMapper tbClueMapper;
    @Autowired
    SysDeptMapper sysDeptMapper;
    @Autowired
    SysUserMapper sysUserMapper;
    @Autowired
    TbBusinessMapper businessMapper;
    @GetMapping("/salesStatistic")
    public AjaxResult sales(@RequestBody Date beginCreateTime, @RequestBody Date endCreateTime) {
        List<String> create_bys = tbClueMapper.createByNames(beginCreateTime, endCreateTime);
        Map<String, Object> map = new HashMap<>();
        for (String create_by : create_bys) {
            map.put("create_by",create_by);
            int dep_id = sysUserMapper.getDeptId(create_by);
            map.put(" dep_id", dep_id);
            String deptName = sysDeptMapper.getDeptName(dep_id);
            map.put("deptName",deptName);
            int num = businessMapper.selectUseTbBusiness(create_by);
            map.put("num",num);
            map.put("radio",100);
        }
        List<Map> list=new ArrayList<>();

        list.add(map);

        return AjaxResult.success(list);
    }

}
